# -*- coding:utf-8 -*-

import uvicorn

from fastapi import FastAPI, APIRouter

from app.events import lifespan
from app.openapi import openapi_docs
from app.middleware import add_middlewares
from app.exception import add_exception_handlers
from app.api import api_router
from app.config import settings

app = FastAPI(lifespan=lifespan,

    openapi_url=settings.SWAGGER_UI_OPENAPI_URL,
    docs_url=settings.SWAGGER_UI_DOCS_URL,
    redoc_url=settings.SWAGGER_UI_REDOC_RL,
)

openapi_docs(app)
app.include_router(api_router, prefix=settings.API_PREFIX)

add_middlewares(app)
add_exception_handlers(app)

if __name__ == '__main__':
    uvicorn.run(app='app.main:app', host='0.0.0.0', port=8000, reload=settings.RELOAD)